package com.quanshu.exchange.ui.gui.profile;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.gyf.barlibrary.ImmersionBar;
import com.quanshu.exchange.R;
import com.quanshu.exchange.support.api.ShopInterface;
import com.quanshu.exchange.support.entity.ConnectionServiceEntity;
import com.quanshu.exchange.support.net.BaseResponse;
import com.quanshu.exchange.support.net.core.BaseObserver;
import com.quanshu.exchange.support.net.core.BaseTransformer;
import com.quanshu.exchange.support.net.core.NetClient;
import com.quanshu.exchange.ui.base.BaseActivity;
import com.quanshu.shop.base.view.BaseTitleBar;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 联系客服
 * Created by xiniu003 on 2018/1/9.
 */

public class ServiceCenterActivity extends BaseActivity {

    @BindView(R.id.service_center_phone)
    TextView serviceCenterPhone;
    @BindView(R.id.service_center_wechat)
    TextView serviceCenterWechat;
    @BindView(R.id.service_center_time)
    TextView serviceCenterTime;
    @BindView(R.id.kf_title)
    BaseTitleBar kfTitle;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_service_center);
        ButterKnife.bind(this);
        ImmersionBar.with(this).titleBar(kfTitle).statusBarColor(R.color.white).statusBarDarkFont(true).init();
        getServiceCenter();
        initListener();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ImmersionBar.with(this).destroy();
    }

    private void initListener() {

        kfTitle.setLeftImage(R.drawable.icon_back_black_2_0).setCenterText("联系客服").setOnClickBaseTitleListener(new BaseTitleBar.OnClickBaseTitleBarListener() {
            @Override
            public void onclickLeft() {
                finish();
            }

            @Override
            public void onclickRight() {

            }
        });


    }

    private void getServiceCenter() {

        NetClient.getInstance().getShopService(ShopInterface.class)
                .getServiceCenter()
                .compose(new BaseTransformer<>(this))
                .subscribe(new BaseObserver<BaseResponse<ConnectionServiceEntity>>() {
                    @Override
                    public void onSuccess(BaseResponse<ConnectionServiceEntity> response) {
                        if (response.getData() != null) {

                            serviceCenterPhone.setText("客服电话：" + response.getData().getPhone());

                            serviceCenterWechat.setText("客服手机：" + response.getData().getWechat());

                            serviceCenterTime.setText("服务时间：" + response.getData().getServiceTime());
                        }
                    }
                });
    }
}
